# Maintainer: DingYuan Zhang <justforlxz@gmail.com>
pkgbase=deepin-anything-git
pkgname=(deepin-anything-git deepin-anything-dkms-git)
pkgver=6.0.7
_extramodules=extramodules-ARCH
pkgrel=1
sourcename=deepin-anything
sourcedir="$sourcename"-"$pkgver"
sourcetars=("$sourcename"-"$pkgver".tar.gz)
pkgdesc="Deepin Anything file search library"
arch=('x86_64' 'aarch64')
url="https://github.com/linuxdeepin/deepin-anything"
license=('GPL3')
groups=('deepin-git')
makedepends=('git' 'libudisks2-qt5-dev' 'libmount-dev' 'libpcre3-dev' 'libnl-genl-3-dev')
source=("${sourcetars[@]}::${url}/archive/refs/tags/${pkgver}.tar.gz"
        deepin-anything-server.sysusers)
sha512sums=('SKIP'
            'SKIP')

prepare() {
 cd $sourcedir
}

build() {
  cd $sourcedir
  make VERSION=$pkgver
}

package_deepin-anything-dkms-git() {
  depends=('dkms')
  provides=('DEEPIN-ANYTHING-MODULE' 'deepin-anything-dkms')
  conflicts=('DEEPIN-ANYTHING-MODULE' 'deepin-anything-dkms')
  cd $sourcedir
  install -dm 755 "$pkgdir"/usr/src
  cp -r src/kernelmod "$pkgdir"/usr/src/$sourcedir
  install -m644 debian/deepin-anything-dkms.dkms "$pkgdir"/usr/src/$sourcedir/dkms.conf
}

package_deepin-anything-git() {
  depends=('DEEPIN-ANYTHING-MODULE' 'libudisks2-qt5-dev' 'libmount-dev' 'libpcre3-dev' 'libnl-genl-3-dev')
  provides=('deepin-anything')
  conflicts=('deepin-anything')
  cd $sourcedir
  make VERSION=$pkgver DESTDIR="$pkgdir" install
  rm -r "$pkgdir"/usr/src
  mv "$pkgdir"/etc/dbus-1/system.d "$pkgdir"/usr/share/dbus-1/system.d
  install -Dm644 ../deepin-anything-server.sysusers "$pkgdir/usr/lib/sysusers.d/deepin-anything-server.conf"
}
